<#include "/include/head.html">
<html>
<title></title>
<body>
<form action="/user/addIndexPhoto" id="photoForm" method="post">
    <input type="text" name="describe" id="describe" placeholder="请输入图片描述">
    <input type="hidden" name="url" id="url">
    <button type="button" onclick="toSub()">点击上传</button>${msg!}
</form>
<form id="formSave" action=""  method="POST" enctype="multipart/form-data">
    <input type="file" id="file"  name="file"  onchange="upload()" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
</form>
</body>
<script>

    function upload() {
        var formData = new FormData($( "#formSave")[0]);
        if(!$('#file').val()){
            return;
        };
        $.ajax({
            url: '/user/qiNiuUpload',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                if (data.status == 1){
                    alert(21222);
                }else{
                    alert(data.info);
                }

            },
            error: function (data) {
                alert("上传图片失败");
            }
        });
    }

    function toSub() {

        if(ifBlank($("#describe").val(),"图片描述不能为空")){
            return
        }
        if(ifBlank($("#password").val(),"图片地址不能为空")){
            return
        }

        $("#photoForm").submit();
    }
</script>
</html>